home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 14642 / 14642.xpi / chrome / content / createCategory.js next >
Text File  |  2009-09-14  |  2KB  |  48 lines

  1. /* Copyright 2009, Boomtango.com.  All Rights Reserved. */
  2. /* createCategory.js
  3.  * Responsible for the create a category window
  4.  */
  5. Components.utils.import("resource://boomtango/app.js");
  6. var mgr = {
  7.     onLoad: function(){},
  8.     onOK: function(){
  9.         var name = document.getElementById("name").value;
  10.         var keywords = document.getElementById("keywords").value;
  11.         var regex = document.getElementById("regex").checked;
  12.         var prompt = Components.
  13.             classes["@mozilla.org/embedcomp/prompt-service;1"] 
  14.             .getService(Components.interfaces.nsIPromptService); 
  15.  
  16.         if(!name.length){
  17.             prompt.alert(window, "Boomtango", boomtangoApp.getString("createc.error.noname"));
  18.             return false;
  19.         } else {
  20.             var types = boomtangoApp.tracker.types;
  21.             for(var x in types){
  22.                 if(types.hasOwnProperty(x)){
  23.                     if(types[x].name == name){
  24.                         prompt.alert(window, "Boomtango", boomtangoApp.getString("createc.error.dupname"));
  25.                         return false;
  26.                     }
  27.                 }
  28.             }
  29.         }
  30.  
  31.         if(!keywords.length){
  32.             prompt.alert(window, "Boomtango", boomtangoApp.getString("createc.error.nokeywords"));
  33.             return false;
  34.         }
  35.  
  36.         var id = boomtangoApp.tracker.createCategoryTracker(name, keywords, regex);
  37.         if(window.arguments && window.arguments.length){
  38.             window.arguments[0].type = id;
  39.         }
  40.         return true;
  41.     },
  42.     onRegexClick: function(){
  43.         var regex = document.getElementById("regex").checked;
  44.         document.getElementById("keyword_desc").
  45.             setAttribute("hidden", !regex);
  46.     }
  47. };
  48.